
#include <QDebug>
#include <cstdlib>
#include <QtGlobal>
#include <QDir>
#include <QDebug>
#include "utils.hpp"
#include "git.hpp"


int main(int argc, char *argv[])
{

    if(argc == 4 || argc == 5)
        {

            if(argc == 5)
                QDir::setCurrent(argv[4]);


            const int major = atoi(argv[1]);
            const int minor = atoi(argv[2]);
            const QString globalRevision = git::getLastCommit();
            const int buildNumber = utils::getBuildNumber(QString(argv[3]));

            qDebug() << major << '.' << minor << '.' << buildNumber
                     << ' ' << qPrintable(globalRevision) ;

            return git::writeFile(argv[3], major, minor, buildNumber, globalRevision);
        }

    qDebug() << "Usage: version_git major minor filename [working dir]" ;
    return 1;

}
